package Morning;

import java.util.HashSet;
import java.util.Iterator;

public class Hash_Set {

    public static void main(String[] args) {
        //hashSet无序
        //重复的元素只打印一遍

        HashSet<String> res = new HashSet<>();


        res.add("李四");
        res.add("王五");
        res.add("菠萝吹雪");
        res.add("李四");
        res.add("李四");
        res.add("王五");


        Iterator<String> iterator = res.iterator();
        while (iterator.hasNext()){

            String  num = iterator.next();
            System.out.println(num);
        }
        System.out.println("---------------------------");

        for (String re : res) {

            System.out.println(re);
            
        }

    }
}
